#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,t1,t2,cnt,head[1000005],nxt[2000005],txt[2000005],f[1000005],tnt,Q[1000005];
vector<int> e;
queue<int> q;
bool v[1000005],vis[1000005];
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
signed main(){
    freopen("choice.in","r",stdin);
    freopen("choice.out","w",stdout);
    n=read();
    for(int i=1;i<n;i++){
        t1=read(),t2=read();
        nxt[++cnt]=head[t1],head[t1]=cnt,txt[cnt]=t2;
        nxt[++cnt]=head[t2],head[t2]=cnt,txt[cnt]=t1;
    }
    v[1]=1;q.push(1);
    while(!q.empty()){
        int t=q.front();q.pop();
        for(int i=head[t];i;i=nxt[i]){
            if(!v[txt[i]]){
                v[txt[i]]=1;
                f[txt[i]]=t;
                q.push(txt[i]);
            }
        }
    }
    vis[1]=1;e.push_back(1);
    for(int i=2;i<=n;i++){
        int t=i;
        while(!vis[t]){
            Q[++tnt]=t;
            vis[t]=1;
            t=f[t];
        }
        while(tnt) e.push_back(Q[tnt--]);
    }
    for(int i=0;i<(int)e.size();i++) cout<<e[i]<<" ";
    return 0;
}